# Maintainer: David Runge <dvzrv@archlinux.org>
# Contributor: Maxim Andersson <thesilentboatman@gmail.com>
# Contributor: NicoHood <archlinux {cat} nicohood {dog} de>

_name=progressbar2
pkgname=python-progressbar
pkgdesc="A progress bar for Python"
pkgver=4.2.0
pkgrel=3
arch=(any)
url="https://github.com/WoLpH/python-progressbar"
license=(BSD)
depends=(
  python
  python-utils
)
makedepends=(
  python-build
  python-installer
  python-setuptools
  python-sphinx
  python-wheel
)
checkdepends=(
  python-pytest
  python-freezegun
)
source=($url/releases/download/v$pkgver/$_name-$pkgver.tar.gz{,.asc})
sha512sums=('d49c154e48bd730c2a7916ed53272ff20cb6fac8c9752734cf645d4701ffcdf25309bf493d03fdc5b6072a85b5f758332fa7448f307d4acc001ad4ab36303a68'
            'SKIP')
b2sums=('7b4d9604626d0944040e59af1b52bf1cf2c045b6a256c7fd4233fa2ee22491484ecb721fe680ad326f7ef383c7070cebad38729c45e91ca2d3b6fcc6c51127a1'
        'SKIP')
validpgpkeys=('149325FD15904E9C4EB89E95E81444E9CE1F695D') # Rick van Hattem <wolph@wol.ph>

build() {
  cd $_name-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  local _site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $_name-$pkgver
  python -m installer --destdir=test_dir dist/*.whl
  export PYTHONPATH="test_dir/$_site_packages:$PYTHONPATH"
  pytest -vv -c /dev/null
}

package() {
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 {CHANGES,CONTRIBUTING,README}.rst -t "$pkgdir/usr/share/doc/$pkgname/"
  install -vDm 644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
}
